

import 'package:huajianshe_app/network/response/BaseResp.dart';
import 'package:huajianshe_app/pages/user_info/model/UserModel.dart';
import 'package:json_annotation/json_annotation.dart';

part 'CircleHomeResp.g.dart';

@JsonSerializable()
class CircleHomeResp extends BaseResp {

  CircleHomeData? data;
  CircleHomeResp();

  factory CircleHomeResp.fromJson(Map<String, dynamic> json) => _$CircleHomeRespFromJson(json);

  @override
  CircleHomeResp parseFromMap(Map<String, dynamic> map) {
    return CircleHomeResp.fromJson(map);
  }
}

@JsonSerializable()
class CircleHomeData {

  @JsonKey(name: 'history_view_circle_list')
  List<BaseHomeCircleInfo>? history;

  @JsonKey(name: 'always_view_circle_list')
  List<RecentHomeCircleInfo>? recent;

  @JsonKey(name: 'recommend_circle_list')
  List<RecommendationHomeCircleInfo>? hot;

  @JsonKey(name: 'interest_circle_list')
  List<RecommendationHomeCircleInfo>? interested;

  @JsonKey(name: 'free_circle_list')
  List<FreeHomeCircleInfo>? free;

  CircleHomeData();

  factory CircleHomeData.fromJson(Map<String, dynamic> json) => _$CircleHomeDataFromJson(json);

}

@JsonSerializable()
class BaseHomeCircleInfo { //顶部一排不知道啥
  @JsonKey(name: 'circle_id')
  int? id;

  @JsonKey(name: 'circle_title')
  String? title;

  BaseHomeCircleInfo();

  factory BaseHomeCircleInfo.fromJson(Map<String, dynamic> json) => _$BaseHomeCircleInfoFromJson(json);
}

@JsonSerializable()
class RecentHomeCircleInfo extends BaseHomeCircleInfo { //最近

  @JsonKey(name: 'cover_url')
  String? cover;

  String? desc;

  @JsonKey(name: 'view_num')
  int? num;

  @JsonKey(name: 'member_number')
  int? memberNum;

  @JsonKey(name: 'circle_member_list')
  List<CircleMember>? circleMembers;

  RecentHomeCircleInfo();

  factory RecentHomeCircleInfo.fromJson(Map<String, dynamic> json) => _$RecentHomeCircleInfoFromJson(json);
}

@JsonSerializable()
class CircleMember {
  @JsonKey(name: 'member_info_box')
  UserInfo? userInfo;

  CircleMember();

  factory CircleMember.fromJson(Map<String, dynamic> json) => _$CircleMemberFromJson(json);
}

@JsonSerializable()
class RecommendationHomeCircleInfo extends BaseHomeCircleInfo { // 每日推荐,热门和感兴趣
  @JsonKey(name: 'friend_number')
  int? num;

  RecommendationHomeCircleInfo();

  factory RecommendationHomeCircleInfo.fromJson(Map<String, dynamic> json) => _$RecommendationHomeCircleInfoFromJson(json);
}

@JsonSerializable()
class FreeHomeCircleInfo extends BaseHomeCircleInfo { //免费洞察
  @JsonKey(name: 'cover_url')
  String? cover;

  @JsonKey(name: 'member_number')
  int? num;

  FreeHomeCircleInfo();

  factory FreeHomeCircleInfo.fromJson(Map<String, dynamic> json) => _$FreeHomeCircleInfoFromJson(json);
}
